package com.hczt.fire.server.config.sercurity;

import com.hczt.fire.server.config.sercurity.interceptor.ContentSecurityInterceptor;
import com.hczt.fire.server.config.sercurity.resolver.ContentSecurityMethodArgumentResolver;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.List;

/**
 * 精诚所至，金石为开。
 * 石の上にも三年;陽気の発する所金石亦透る。
 * Faith moves mountains.
 *
 * @author marvin.ma
 * @create 2017-11-30 6:52
 * @desc springMVC 注解式配置类
 **/
@Configuration
public class WebMvcConfiguration extends WebMvcConfigurerAdapter {

    /**
     * 配置拦截器
     * @Auther: marvin.mma
     * @Date: 2017/11/30 6:55
     * @return   
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new ContentSecurityInterceptor()).addPathPatterns("/**");
        //registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**");
    }

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolverList) {
        /**
         * 将自定义的参数装载添加到spring内托管
         */
        argumentResolverList.add(new ContentSecurityMethodArgumentResolver());
    }

}
